package com.cml.dm.engine.config;

import com.cml.dm.engine.model.Task;
import org.dom4j.Element;

import java.util.Iterator;
import java.util.List;

public class TaskXmlNodeParser<T> implements  XmlNodeParser{
    public void parser(List list, Element el) {
        Task task = new Task();
        task.setId(el.attributeValue("id"));
        task.setVersion(el.attributeValue("version"));
        task.setLazy(Boolean.parseBoolean(el.attributeValue("lazy")));
        if(null != el.attributeValue("threadNum")){
            task.setThreadNum(Integer.parseInt((String)el.attributeValue("threadNum")));
        }
        list.add(task);

        for(Iterator i = el.elementIterator(); i.hasNext();){
            Element elTemp = (Element) i.next();
            XmlNodeParserFactory.getXmlNodeParser(elTemp).parser(task.getNodeList(),elTemp);
        }
    }
}
